<template>
  <div id="club-detail">
    <div class="container">
      <div class="left">
        <ClubLeftComponent v-if="clubDetail" :club="clubDetail" />
      </div>
      <div class="right">
        <div class="top">
          <ClubTopComponent v-if="clubDetail" :club="clubDetail" />
        </div>
        <div class="bottom">
          <ClubBottomComponent v-if="clubDetail" :club="clubDetail" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from 'axios';
import ClubLeftComponent from "@/components/club-detail/ClubLeftComponent.vue";
import ClubTopComponent from "@/components/club-detail/ClubTopComponent.vue";
import ClubBottomComponent from "@/components/club-detail/ClubBottomComponent.vue";

export default {
  name: 'ClubDetail',
  components: {ClubBottomComponent, ClubTopComponent, ClubLeftComponent},
  data() {
    return {
      clubId: null,
      clubDetail: null,
    }
  },
  created() {
    this.clubId = this.$route.query.clubId;
    this.fetchClubDetails();
  },
  methods: {
    async fetchClubDetails() {
      try {
        const response = await axios.post('/club/clubInfo', null, {
          params:{clubId: this.clubId}
        });
        if (response.data.code === 0) {
          this.clubDetail = response.data.data;
          console.log(response)
        } else {
          console.error('Failed to fetch club details:', response.data.message);
        }
      } catch (error) {
        console.error('Error fetching club details:', error);
      }
    }
  }
}
</script>

<style scoped>
#club-detail {
  background-color: #FFE7C7;
  min-height: 100vh;
  padding: 15px;
  box-sizing: border-box;
}

.container {
  display: flex;
  height: calc(100vh - 30px);
  gap: 20px; /* 增加了容器之间的间隔 */
  max-width: 1400px;
  margin: 0 auto;
}

.left {
  flex: 1;
  background-color: #ffffff;
  border-radius: 12px;
  padding: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.right {
  flex: 2;
  display: flex;
  flex-direction: column;
  gap: 20px; /* 增加了上下容器之间的间隔 */
}

.top {
  flex: 1;
  height: 50vh;
  background-color: #ffffff;
  border-radius: 12px;
  padding: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  overflow: auto;
}

.bottom {
  flex: 3;
  background-color: #ffffff;
  border-radius: 12px;
  padding: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  overflow: auto;
}

@media (max-width: 1024px) {
  .container {
    flex-direction: column;
    height: auto;
    gap: 15px; /* 在小屏幕上稍微减小间隔 */
  }

  .left, .right {
    width: 100%;
  }

  .left {
    height: 35vh;
  }

  .top {
    height: 18vh;
  }

  .bottom {
    height: 35vh;
  }

  .right {
    gap: 15px; /* 在小屏幕上稍微减小上下容器之间的间隔 */
  }
}
</style>
